//
//  MIDIconfirmController.m
//  迷笛
//
//  Created by . on 2018/9/14.
//  Copyright © 2018年 🍃🌺🌺🍃. All rights reserved.
//

#import "MIDIconfirmController.h"
#import "MIDIConfirmCell.h"
#import "MIDIwinController.h"
#import "MIDIdefeatedController.h"
@interface MIDIconfirmController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView * ControllTable;
@property(nonatomic,strong)UILabel * blacklable;
@property(nonatomic,strong)UIButton * Next;
@end

@implementation MIDIconfirmController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *leftBarItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(Block:)];
    self.navigationItem.leftBarButtonItem = leftBarItem;
    
    [self.navigationItem.leftBarButtonItem setImage:[[UIImage imageNamed:@"后退"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    [self HomeUI];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
{
    return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
    if (section == 0)
    {
    return 3;
    }
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    static NSString * cellID = @"cell";
    MIDIConfirmCell * cell =[tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell)
    {
        cell =[[MIDIConfirmCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
        [_ControllTable setSeparatorColor : [UIColor blackColor]];
        cell.backgroundColor =[UIColor colorWithHexString:@"#1B212F"];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;

    }
    
    if (indexPath.section == 0)
    {
        if (indexPath.row == 0)
        {
            cell.tickname.text =@"电子票";
        }
        if (indexPath.row == 1)
        {
//            NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"取票人姓名" attributes:
//                                              @{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#999999"],
//                                                NSFontAttributeName:cell.name.font
//                                                }];
//            cell.name.attributedPlaceholder = attrString;
         
        cell.name.placeholder = @"取票人姓名";

        }
        if (indexPath.row == 2)
        {
            cell.name.placeholder = @"取票人手机号";
        }
    }
    if (indexPath.section == 1)
    {
        if (indexPath.row == 0)
        {
            cell.mainiamge.image = [UIImage imageNamed:@"IMG_0195.jpg"];
            cell.address.text = @"北部湾（钦州）迷笛音乐节";
            cell.time.text = @"场次：2018-09-03  12:00";
            cell.RMB.text = @"价格：780元*1张";
        }
    }
    if (indexPath.section == 2)
    {
        if (indexPath.row == 0)
        {
            cell.addressimage.image =[UIImage imageNamed:@"huodong-location"];
            cell.addresslable.text = @"北京市朝阳区朝阳公园325号创意产业园7号楼 SDlivehouse";
        }
    }
    if (indexPath.section == 3)
    {
        if (indexPath.row == 0)
        {
            cell.ticketrmb.text = @"票款";
            cell.Yuan.text = @"780元";
        }
    }
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
 
    if (indexPath.section == 1)
    {
        return 152;
    }
    if (indexPath.section == 2)
    {
        return 70;
    }
    return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;
}
- ( UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
{
    return nil;
}
- ( UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
{
    return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}
//视图将要出现时（导航颜色字体颜色）
- (void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithHexString:@"#171717"];
    self.navigationController.navigationBar.translucent = NO;//Bar的模糊效果，默认为YES
    self.title = @"确认订单";
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#FFFFFF"],NSFontAttributeName : [UIFont fontWithName:@"Helvetica-Bold" size:WidthScale(17)]}];
    //    去掉导航黑线
    UIImage *img = [UIImage imageNamed:@""];
    [self.navigationController.navigationBar setBackgroundImage:img  forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];
}
// 返回上一级
-(void)Block:(UIButton * )sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)HomeUI
{
    [self.view addSubview:self.ControllTable];
    [self.view addSubview:self.blacklable];
    [self.blacklable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_offset(kDevice_Is_iPhoneX?HeighX(-34):HeightScale(0));
        make.left.mas_offset(WidthScale(0));
        make.width.mas_offset(WidthScale(240));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(49):HeightScale(49));
    }];
    [self.view addSubview:self.Next];
    [self.Next mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.blacklable);
        make.left.equalTo(self.blacklable.mas_right).offset(WidthScale(0));
        make.width.mas_offset(WidthScale(135));
        make.height.mas_offset(kDevice_Is_iPhoneX?HeighX(49):HeightScale(49));
    }];
}
-(UITableView *)ControllTable
{
    if (!_ControllTable)
    {
        _ControllTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
        _ControllTable.dataSource = self;
        _ControllTable.delegate = self;
        _ControllTable.backgroundColor = [UIColor colorWithHexString:@"#171717"];
    }
    return _ControllTable;
}
-(UILabel *)blacklable
{
    if (!_blacklable)
    {
        _blacklable = [[UILabel alloc]init];
        _blacklable.text = @"780元";
        _blacklable.textColor =[UIColor whiteColor];
        _blacklable.backgroundColor =[UIColor blackColor];
        _blacklable.textAlignment = NSTextAlignmentCenter;
        _blacklable.font =[UIFont systemFontOfSize:WidthScale(20)];
    }
    return _blacklable;
}
-(UIButton *)Next
{
    if (!_Next)
    {
        _Next =[[UIButton alloc]init];
        [_Next setBackgroundColor:[UIColor colorWithHexString:@"#FF005D"]];
        [_Next setTitle:@"提交订单" forState:UIControlStateNormal];
        [_Next addTarget:self action:@selector(Next:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _Next;
}
-(void)Next:(UIButton * )sender
{
    MIDIwinController * win =[[MIDIwinController alloc]init];
    [self presentViewController:win animated:YES completion:nil];
}


@end
